package cn.quevo.ucenter.core.entity;

import java.util.Set;

import cn.quevo.core.entity.DoEntity;
import cn.quevo.core.entity.UserInfoDetails;
import cn.quevo.core.lang.StringUtils;
import cn.quevo.core.util.CollectionUtil;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = true)
public class User extends DoEntity implements UserInfoDetails {

    /**
     *
     */
    private static final long serialVersionUID = -2611881780482241594L;
    /** 用户ID */
    private Long userId;
    /** 用户主体ID */
    private Long subjectId;
    /** 用户账号 */
    private String userName;
    /** 用户密码 */
    private String password;
    /** 昵称 */
    private String nickName;
    /** 角色字符串 */
    private String roleStr;
    /** 权限字符串 */
    private String permissionStr;
    /** 企业ID */
    private Long compId;
    /** 用户状态 */
    private String userStatusCd;

    private Boolean admin;
    private Boolean supper;
    @Override
    public Set<String> getRoles() {
        return CollectionUtil.asSet(this.roleStr);
    }

    @Override
    public Set<String> getPermissions() {
        return CollectionUtil.asSet(this.permissionStr);
    }

    public Boolean isAdmin() {
        return !StringUtils.isEmpty(getRoles()) && getRoles().contains("ADMIN");
    }
    public Boolean isSupper() {
        return !StringUtils.isEmpty(getRoles()) && getRoles().contains("SUPPER");
    }

}
